package org.lanqiao.lg.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.lanqiao.bean.Founder;
import org.lanqiao.lg.dao.FounderDao;
import org.lanqiao.tools.BaseDao;

public class FounderDaoImpl extends BaseDao implements FounderDao {

//	@Override 根据id查询创始人
	public Founder selectFounderById(Integer id) {
		try {
			return query.query("select * from founder where id=?", new BeanHandler<Founder>(Founder.class), id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

//	@Override 插入 创始人
	public Integer insertFounder(Founder info) {
		try {
			return query.update(
					"INSERT INTO founder(name,position,com,introduction,imgId,companyId,stateId,date) VALUES(?,?,?,?,?,?,1,NOW())",
					info.getName(), info.getPosition(), info.getCom(), info.getIntroduction(), info.getImgId(),
					info.getCompanyId());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

//	@Override 查询公司创始人信息
	public List<Map<String, Object>> selectFounderByCId(Integer cid) {
		try {
			return query.query("select * from founder where companyid=? LIMIT 0,2", new MapListHandler(),cid);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
